iT邦幫忙

2024 iThome 鐵人賽

DAY 15
0
IT 管理

API Gateway:微服務世界的守護者系列 第 15

Day 15 - Kubernetes FQDN

  • 分享至 

  • xImage
  •  

https://ithelp.ithome.com.tw/upload/images/20240929/20111516BRHFZEoQyQ.png

Understanding FQDNs in Kubernetes Services

FQDN (Fully Qualified Domain Name) is a hierarchical name that uniquely identifies a device on a network. In the context of Kubernetes, FQDNs are primarily used for Services.

The Structure of a Kubernetes Service FQDN

A typical Kubernetes Service FQDN follows this format:

<service-name>.<namespace>.svc.cluster.local

Where:

  • : The name you've given to your Kubernetes Service.
  • : The namespace where the Service is defined.
  • svc.cluster.local: The default domain suffix for Kubernetes Services.

Example

Consider a Service named "myapp" in the "default" namespace. Its FQDN would be:

myapp.default.svc.cluster.local

Why Use FQDNs for Services?

  1. Abstraction: FQDNs provide an abstract way to reference Services, decoupling your applications from the underlying IP addresses.
  2. Service Discovery: Kubernetes automatically creates DNS records for Services, allowing clients to resolve the FQDN to the correct IP address.
  3. Portability: FQDNs can be used consistently across different environments, making your applications more portable.

Accessing Services with FQDNs

You can access a Service using its FQDN from within the Kubernetes cluster. For example, to curl a Service named "myapp":

kubectl exec -n default mypod -- curl myapp.default.svc.cluster.local

Note: The specific method for accessing Services from outside the cluster might vary depending on your network configuration and the type of Service (e.g., NodePort, LoadBalancer, Ingress).

By understanding the structure and purpose of FQDNs in Kubernetes, you can effectively manage and access your Services within the cluster.


上一篇
Day 14 - 架構&服務之間
下一篇
Day 16 - APISIX Plugin - api-breaker
系列文
API Gateway:微服務世界的守護者24
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言